import uuid
from typing import TypeVar

from sqlalchemy.orm import Mapped, mapped_column, relationship

from recruit.adapter.database.models import Base

Resume = TypeVar('Resume')


class User(Base):
    """ Model User. """
    id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
    user_id: Mapped[str] = mapped_column(
        nullable=False,
        unique=True,
        comment='Уникальный индентификатор пользователя'
    )
    username: Mapped[str] = mapped_column(
        nullable=False,
        comment="Юзернейм пользователя"
    )
    resume: Mapped[list['Resume']] = relationship(
        back_populates='user',
        lazy='selectin',
        cascade='all, delete-orphan',
    )
